#!/usr/bin/env bash
source /etc/profile

if [ -n "$2" ]; then
  do_date=$1
  table_name=$2
else
  echo "need 2 parameters"
  exit 2
fi

hdfs dfs -mkdir -p /user/data/trade.db/$table_name/dt=$do_date

python $DATAX_HOME/bin/datax.py -p "-Ddo_date=$do_date" /root/scripts/datax/export_$table_name.json

hive -e "alter table ods.ods_trade_$table_name add partition(dt='$do_date');"